<!DOCTYPE html>
<html>

<head lang="en">
	<title>首页</title>
	<meta charset="utf-8" />
	<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
	<link rel="stylesheet" href="/js/bootstrap/css/bootstrap.min.css">
	<script src="/js/jquery/jquery.min.js"></script>
	<script src="/js/bootstrap/js/bootstrap.min.js"></script>
	<script src="/js/plugins/jrender/jrender.min.js"></script>
	<link rel="stylesheet" href="/css/font/css/font-awesome.min.css">
	<link rel="stylesheet" href="/css/reset.css" rel="stylesheet" >
	<link rel="stylesheet" href="/css/index.css" rel="stylesheet">
	<link rel="stylesheet" href="/js/plugins/dialog2/dialog.css">
	<script src="/js/plugins/dialog2/dialog.min.js"></script>

	<link rel="stylesheet" href="js/plugins/chosen/component-chosen.css">
	<script src="js/plugins/chosen/chosen.jquery.js"></script>

	<link rel="stylesheet" href="/js/bootstrap/css/bootstrap.min.css">
	<script src="/js/bootstrap/js/bootstrap.min.js"></script>
	<link rel="stylesheet" href="/css/strategy.css" />
	<link rel="stylesheet" href="/js/plugins/chosen/component-chosen.css">
	<script>

        $(function () {
            //查询功能

            $.get('strategys', {pageSize:0}, function (data) {



                $('#strategies').append("<option value='-1'>-寻找攻略-</option>")

                var op = "";
                $.each(data, function (index, item) {
                    op+= "<option value='"+item.id+"'>"+item.title+"</option>"
                })



                $("#strategies").append(op);
                $("#strategies").chosen({
                    no_results_text: "无相关地区!",//搜索无结果时显示的提示
                    disable_search_threshold: 5,//选项小于5时不显示搜索框
                    search_contains:true,   //关键字模糊搜索，设置为false，则只从开头开始匹配
                    allow_single_deselect:true, //是否允许取消选择
                    max_selected_options:6  //当select为多选时，最多选择个数
                })
                $('.chosen-select').on('change', function(e, params) {
                    console.log(params);
                    window.location.href="/strategyCatalogs.html?strategyId="+params.selected
                });
            })

            //查询推荐状态的日报
            $.get('/dailies/state',{state:1,pageSize:1},function (data) {
                $("#bigger").renderValues({list:data.list},{
                    setHref:function (item,value) {
                        var href = $(item).data("href"); //得到href
                        $(item).attr("href",href + value);//手动拼接跳转的url
                    }
                })

            })

            //分页查询需要拼接的临时变量
            var currentPage = 1;
            //解决上一1页时数据丢失的问题
            var dataList = [];
            //总页数变量
            var totalPage = 1;
            function query() {
                //查询普通状态的日报
                $.get('/dailies', {state: 0, currentPage: currentPage}, function (data) {
                    //每一次查询完将数据保存到数组中,并且合并数据
                    dataList = $.merge(dataList, data.list);

                    $("#smaller").renderValues({list: dataList}, {
                        setHref: function (item, value) {
                            var href = $(item).data("href"); //得到href
                            $(item).attr("href", href + value);//手动拼接跳转的url
                        }
                    })
                    //第一页数据,,,每次查询完之后页面加一
                    currentPage += 1;
                    //将第一查询的总页数封装成变量
                    totalPage = data.pages;
                })
            }
            //第一次查询
            query();
            //屏幕滚动事件
            $(window).scroll(function () {
                //触发翻页的ajax去查询
                //触发翻页的时机.  屏幕高度+滚动高度>=数据的高度的时候
                if ($(window).height()+$(document).scrollTop()>=$(document).height()) {
                    //解决翻页底部问题,一直发送请求,如果当前页小于总页数的时候
                    if (currentPage <= totalPage) {
                        query();
                    } else {
                        //已经到最后一页
                        $(document).dialog({
                            type: "notice",
                            infoText: "到底了........",
                            autoClose: 1000,
                            position: "bottom" //在底部显示
                        })
                    }
                }
            })







            //查询周推荐
			$.get('/travels/commends',{type:0,pageSize:3},function (data) {
				$('#travelsCommends').renderValues(data,{
				    setHref:function (item,value) {
                        var href = $(item).data("href"); //得到href
                        $(item).attr("href",href + value);//手动拼接跳转的url
                    }

				});
				$('#loopPlay:first').addClass("active")
            })


			showComments();


        })

		function showComments(){
			var Mar = document.getElementsByClassName("Marquee")[0];
			var child_div=Mar.getElementsByTagName("div");
			var picH = 50;//移动高度
			var scrollstep=3;//移动步幅,越大越快
			var scrolltime=20;//移动频度(毫秒)越大越慢
			var stoptime=3000;//间断时间(毫秒)
			var tmpH = 0;
			Mar.innerHTML += Mar.innerHTML;
			function start(){
				if(tmpH < picH){
					tmpH += scrollstep;
					if(tmpH > picH )tmpH = picH ;
					Mar.scrollTop = tmpH;
					setTimeout(start,scrolltime);
				}else{
					tmpH = 0;
					Mar.appendChild(child_div[0]);
					Mar.scrollTop = 0;
					setTimeout(start,stoptime);
				}
			}
			setTimeout(start,stoptime)
		}
	</script>



</head>


<body>

<div class="body">
	<input type="checkbox" id="menu">

	<label for="menu" class="menu">
		<span><i class="fa fa-user fa-fw fa-2x"></i></span>
		<span><i class="fa fa-chevron-left fa-fw fa-2x" style="color: #3E3C3B"></i></span>
	</label>

	<!-- 侧边栏 导航栏 -->
	<div class="nav">
		<iframe id="ipage" src="/mine/simpleProfiles.html" frameborder="0" width="90%"></iframe>
	</div>

	<div class="search-head">
		<div class="row nav-search">
			<div class="col-2"></div>
			<div class="col-10">
				<div class="input-group-sm search" >
					<select id="strategies" class="chosen-select form-control" name="strategy.id"
							render-value="strategy.id" placeholder="查询">
					</select>
				</div>
			</div>
		</div>
	</div>

	<div class="container">
		<h6 class="module-title">每周推荐</h6>
		<div id="carouselExampleControls" class="carousel slide" data-ride="carousel">
			<div id="travelsCommends">
				<div class="carousel-inner" render-loop="list">
					<div class="carousel-item " id="loopPlay">
						<a data-href="/travelContent.html?id=" render-fun="setHref" render-key="list.travel_id">
							<img class="d-block w-100"  render-src="list.coverUrl">
							<span class="recommend" render-html="title" ></span>
						</a>
						<div class="recommend-author"><a href="#">
							<img  class="rounded-circle" style="width: 10%;" render-src="list.u_headImgUrl">
							<span render-html="list.u_nickName"></span>
							</a>在&nbsp;
							<span render-html="list.r_name">广州</span>
						</div>
					</div>
				</div>
			</div>
			<a class="carousel-control-prev" href="#carouselExampleControls" role="button" data-slide="prev">
				<span class="carousel-control-prev-icon" aria-hidden="true"></span>
				<span class="sr-only"></span>
			</a>
			<a class="carousel-control-next" href="#carouselExampleControls" role="button" data-slide="next">
				<span class="carousel-control-next-icon" aria-hidden="true"></span>
				<span class="sr-only"></span>
			</a>
		</div>
		<hr>

		<div class="row nav-box">
			<div class="col" style="background-color: #DFE823;" align="center">
				<a href="strategyPage.html"><i class="fa fa-plane fa-fw"></i> 找攻略</a>
			</div>
			<div class="col" style="background-color: #7281D5;" align="center">
				<a href="travelPage.html"><i class="fa fa-book fa-fw"></i> 看游记</a>
			</div>
		</div>

		<div class="row dynamic " id="comments">
			<div class="col-1" style="padding: 0px;">
				<img class="rounded" src="/img/topComment.png" style="width: 50px;">
			</div>
			<div class="col">
				<div class="Marquee"  >
					<div class="d-flex">
					<a href="/friend/profiles.html?id=1" >
						<img  class="rounded-circle dynamic-head" src="http://plgps4ivn.bkt.clouddn.com/FuPkntcn7TxHkUw8TJ6SXlLZ8mr9">
					</a>
					<a href="/friend/profiles.html?id=1"  class="dynamic-detail" data-id="1">
						<span>hanfe</span> 点评了攻略<p >广州攻略</p>
					</a>
				</div><div class="d-flex">
					<a href="/friend/profiles.html?id=2" >
						<img class="rounded-circle dynamic-head" src="/upload/23a45130-e59c-4844-bc52-67aed3d57fc1.jpeg">
					</a>
					<a href="/friend/profiles.html?id=2"  class="dynamic-detail" >
						<span >hui</span> 点评了攻略<p >广州攻略</p>
					</a>
				</div></div>
			</div>
		</div>
	</div>

	<hr>

	<div class="container news" >
		<h6 class="module-title">骡窝日报
			<a href="newsPage.html" >更多</a>  </h6>
		<div  id="bigger">
			<div render-loop="list">
			<a data-href="newsContent.html?id=" render-fun="setHref" render-key="list.id">
				<img width="100%" render-src="list.coverUrl">
				<div class="caption">
					<h5 render-html="list.title"></h5>
					<p render-html="list.subTitle">
					</p>
				</div>
			</a>
			</div>
		</div>
		<hr>
		<div id="smaller">
			<div style="margin-bottom: 20px" render-loop="list">
			<a data-href="newsContent.html?id=" render-fun="setHref" render-key="list.id">
				<div class="row news-detail">
					<div class="col-5">
						<img render-src="list.coverUrl">
					</div>
					<div class="col-7">
						<h4 render-html="list.title"></h4>
						<p render-html="list.subTitle"></p>
						<p>
							<i class="fa fa-eye fa-fw"></i>
							<span>5</span>
							<i class="fa fa-commenting fa-fw"></i>
							<span>2</span>
						</p>
					</div>
				</div>
			</a>
			<hr>
		</div>

		</div>
	</div>
</div>



</body>

</html>